cj_editor.autoMinHeight = function(){
	var win_height = $(window).height(),
	  head_height = $('.yinji_templates_PictureStory_head').outerHeight(true),
	  bottom_height = $('.yinji_templates_PictureStory_bottom').outerHeight(true),
	  mess_height = win_height - head_height - bottom_height,
	  odd_height = $("#mess_ul").outerHeight(true);
	if (mess_height > 0) {
		$('#mess_ul').css('minHeight', mess_height);
	}
	if ($('.yinji_templates_PictureStory_box').hasClass('PictureStory_view_box')) {
		document.getElementById('title').readOnly=true;
		$('#title').click(function() {
			$('#title').blur();
		});
	}else{
		$('.set_cover').css('display', 'block');
		$('.set_time').children('img').css('display', 'inline-block');
	}

	var cover_pic_width = $('.yinji_templates_PictureStory_box').width();
	var cover_pic_height = cover_pic_width / 1.6304;
	$('#cover_pic').css({'height':cover_pic_height});
}

cj_editor.load_user_mess_text = function(mess){   //载入用户内容(文字类)
	if(mess == ""){
		return;
	}
	var user_mess = mess;   //内容数据
	var html_text = '<li class="mess_text add_newmess_animation"><div class="yinji_templates_PictureStory_tool animation_tool"><img src="images/btn_delete.png" id="delete" class="delete"></div><p class="text_editor editor_default yinji_edit_text yinji_sethtml_text"></p></li>';
	$('#mess_ul').append(html_text);
	if(mess != ""){
		$('.yinji_sethtml_text').append(user_mess);
		$('.yinji_sethtml_text').removeClass("yinji_sethtml_text");
	}
}

cj_editor.load_user_mess_pic = function(mess,src){   //载入用户内容(图片类)
	var user_mess = mess;   //文字内容数据
	var user_pic_src = src   //图片内容数据
	var user_location = '';
	/*
	if(location_mess){
		user_location = '<div class="imformation"><div class="location"><img src="images/icon_location.png" class="icon_location"><i>' + location_mess + '</i></div></div>';
	}
	*/
	if(mess == ""){
		var html_pic = '<li class="mess_pic add_newmess_animation"><div class="yinji_templates_PictureStory_tool animation_tool"><img src="images/btn_delete.png" id="delete" class="delete"><img src="images/btn_cut.png" id="cut" class="cut"></div><div class="inner_pic"><img src="' + user_pic_src +'" class="user_pic"></div>' + user_location + '</li>';
	}else{
		var html_pic = '<li class="mess_pic add_newmess_animation"><div class="yinji_templates_PictureStory_tool animation_tool"><img src="images/btn_delete.png" id="delete" class="delete"><img src="images/btn_cut.png" id="cut" class="cut"></div><div class="inner_pic"><img src="' + user_pic_src +'" class="user_pic"></div>' + user_location + '<p class="text_editor yinji_sethtml_text"></p></li>';
	}

	$('#mess_ul').append(html_pic);
	if(mess != ""){
		$('.yinji_sethtml_text').append(user_mess);
		$('.yinji_sethtml_text').removeClass("yinji_sethtml_text");
	}
}

//new
cj_editor.check_view_style = function(){   //浏览&编辑状态间的细节样式处理（display）
	var win_height = $(window).height(),
	  head_height = $('.yinji_templates_PictureStory_head').outerHeight(true),
	  bottom_height = $('.yinji_templates_PictureStory_bottom').outerHeight(true),
	  mess_height = win_height - head_height - bottom_height,
	  odd_height = $("#mess_ul").outerHeight(true);
	if (mess_height > 0) {
		$('#mess_ul').css('minHeight', mess_height);
	};
	if ($('.yinji_templates_PictureStory_box').hasClass('PictureStory_view_box')) {
		document.getElementById('title').readOnly=true;
		$('#title').click(function() {
			$('#title').blur();
		});
	}else{
		$('.set_cover').css('display', 'block');
		$('.set_time').children('img').css('display', 'inline-block');
	}
}

cj_editor.init = function(data,usetype){
	cj_editor.adaptive_size(720,100);
	$(".yinji_templates_PictureStory_box").addClass('PictureStory_view_box');
	cj_editor.autoMinHeight();
	cj_editor.init_run(false,usetype);
	
	var showData = '';
	if(data == ""){
		showData = {"yinji_title":"拾起心情录","yinji_describe":"","yinji_templates_cover":{"type":"image","value":"images/1.jpg","attachment":"true"},"yinji_templates_datalist":{"type":"text","value":{"0":{"text":" 吹了好久的夜风，直到全身哆嗦时才抬腿回家。猛然发现，我在逃避。我不想回家，曾经我把这个家当成我的一切。而现在，内心里只有恐惧。其实有的东西，就是自作自受。既然懦弱接受新的生活，那你活该煎熬。明天二十了，就算明天谁也不知道。你不准哭，因为你早已麻木了！","type":"text"},"1":{"text":"日出","type":"image","src":"images/2.jpg"},"2":{"text":"看到跳舞的小朋友从大巴车上下来，突然明白我为什么不开心了。好想学东西奈与现实。那个大巴车在我心里是期盼的它像夜色的的巨人！","type":"text"},"3":{"text":"小船浆","type":"image","src":"images/3.jpg"}},"attachment":"true"},"yinji_templates_date":"2017.6.1"};	
	}else{
		showData = JSON.parse(data);
	}
	cj_editor.setHTML(showData);
	if($.isFunction(cj_editor.title_editor)){
		cj_editor.title_editor();
	}
	cj_editor.autoImg();
}